<extend name="base" />
<block name="CONTENT">
    <!--开始 商品调价-->
    <div class="contextMargin">
        <div class="col-sm-12 marginBottom30">
            <!--<div class="color9 size14">当前位置：商品调价>商品管理</div>-->
        </div>
        <div class="shopTable shopBorder">
            <ul class="shopNav shopNav-tabs">
                <li class="active">
                    <img src="Application/Home/Static/bt/img/user/manage.png"/>
                    <span>商品调价</span>
                </li>
                <li id="choiceModifypricehistoryPagination">
                    <img src="Application/Home/Static/bt/img/user/record.png"/>
                    <span>调价记录</span>
                </li>
            </ul>
        </div>

        <div class="shoptable1">
            <div class="shopContainer">
                <div class="btnGounp">
                    <button class="shopBtn size16" style="display: none;">批量操作</button>
                    <button class="shopBtn size16 readjustClick" data-toggle="modal" data-target="#readjustModal" style="display: none;">一键调库存</button>
                    <button class="shopBtn size16 shopBtnWH exportProductData" style="margin-right: 0!important;">导出</button>
                    <form id="addform" action="{:U('admin/goods/upload')}" method="post" enctype="multipart/form-data">
                        <input name="id" type="hidden" value="{$goods_info.id}" />
                        <div class="control-group">
                            <label>Excel表格：</label>
                            <input type="file" name="excelData" value=""  datatype="*4-50"  nullmsg="请填写产品！" errormsg="不能少于4个字符大于50个汉字"/>
                            <span class="Validform_checktip"></span>
                        </div>



                        <div class="control-group">
                            <img style="display:none;" src="images/loading.gif" />
                            <input type="submit" class="btn btn-primary Sub" value="导入" />
                        </div>
                    </form>
                </div>

                <div class="clearFix inputContai productScreen">

                    <div class="col-lg-2 col-md-4 col-sm-12 col-xs-12 labeiTop20 shopleft0 shopright0 shopMd">
                        <div class="col-lg-10 col-md-10 col-sm-11 shopleft0 shopright0 shopPosition">
                            <input class="shopInputs shopFloat proportionInput" name="ASINorSKU" type="text" placeholder="输入ASIN、SKU、商品名称" style="border:0;width:100%"/>
                            <i class="ace-icon fa fa-times shopClose productShopClose" style="display: none"></i>
                        </div>

                        <div class="col-lg-1 shopleft0 shopright0  mediaLeft productSearch">
                                <span class=" input-icon">
                                    <i class="ace-icon fa fa-search nav-search-icon "></i>
                                </span>
                        </div>
                    </div>

                    <div class="col-lg-2 col-md-4 col-sm-12 col-xs-12 labeiTop20 shopleft0 shopright0 shopMd menuClick menuBtn">
                        <input type="hidden" name="listingStatus"/>
                        <input class="shopInputs shopFloat proportionInput col-lg-10 col-md-10 col-sm-11 shopIRigth5" type="text" placeholder="按listing状态" style="border:0;" disabled/>
                        <div class="input-group-btn shopCenter mediaRight4 mediaSm inputMenu">
                            <button type="button" class="btns dropdown-toggle" style="background:#E9E9E9!important;" aria-haspopup="true" aria-expanded="false">
                                <b class="arrow fa fa-angle-down dwonStle"></b>
                            </button>
                            <ul class="dropdown-menu downBtnSM proportion">
                                <li><a href="#">全部</a></li>
                                <li><a href="#" value="1">可售</a></li>
                                <li><a href="#" value="2">不可售</a></li>
                            </ul>
                        </div>
                    </div>

                    <div class="col-lg-2 col-md-4 col-sm-12 col-xs-12 labeiTop20 shopleft0 shopright0 shopMd statuInpu menuClick menuBtn">
                        <input type="hidden" name="buyboxStatus"/>
                        <input class="shopInputs shopFloat proportionInput col-lg-10 col-md-10 col-sm-11 shopIRigth10" disabled type="text" placeholder="按Buybox状态" style="border:0;"/>
                        <div class="input-group-btn shopDRingth mediaSm inputMenu">
                            <button type="button" class="btns dropdown-toggle btnMedia" style="background:#E9E9E9!important;" aria-haspopup="true" aria-expanded="false">
                                <b class="arrow fa fa-angle-down dwonStle"></b>
                            </button>
                            <ul class="dropdown-menu downBtn mediaDownBtn proportion">
                                <li><a href="#">全部</a></li>
                                <li><a href="#" value="1">抢占</a></li>
                                <li><a href="#" value="2">未抢占</a></li>
                            </ul>
                        </div>
                    </div>

                    <div class="col-lg-2 col-md-4 col-sm-12 col-xs-12 labeiTop20 shopleft0 shopright0 shopMd statuInpu">
                        <div class="col-lg-10 col-md-10 col-sm-11 shopleft0 shopright0 shopPosition">
                            <input class="shopInputs shopFloat proportionInput col-lg-10 col-md-10 col-sm-11" name="quantity" type="text" placeholder="按可售数量<=" style="border:0;width:100%"/>
                            <i class="ace-icon fa fa-times shopClose productShopClose" style="display: none"></i>
                        </div>

                        <div class="col-lg-1 shopleft0 shopright0 mediaLeft productSearch">
                                <span class=" input-icon">
                                    <i class="ace-icon fa fa-search nav-search-icon "></i>
                                </span>
                        </div>
                    </div>

                    <div class="col-lg-2 col-md-4 col-sm-12 col-xs-12 labeiTop20 shopleft0 shopright0 shopMd statuInpu menuClick">
                        <input type="hidden" name="FBAorFBM"/>
                        <input class="shopInputs shopFloat proportionInput col-lg-10 col-md-10 col-sm-11 shopIRigth5" type="text" placeholder="按发货类型" disabled style="border:0;"/>
                        <div class="input-group-btn shopCenter mediaRight4 mediaSm inputMenu">
                            <button type="button" class="btns dropdown-toggle" style="background:#E9E9E9!important;" aria-haspopup="true" aria-expanded="false">
                                <b class="arrow fa fa-angle-down dwonStle"></b>
                            </button>
                            <ul class="dropdown-menu downBtnSM proportion">
                                <li><a href="#">全部</a></li>
                                <li><a href="#" value="FBA">FBA</a></li>
                                <li><a href="#" value="FBM">FBM</a></li>
                            </ul>
                        </div>
                    </div>

                    <div class="col-lg-2 col-md-4 col-sm-12 col-xs-12 labeiTop20 shopleft0 shopright0 shopMd inputLeft menuClick">
                        <input type="hidden" name="shopName">
                        <input class="shopInputs shopFloat proportionInput col-lg-10 col-md-10 col-sm-11 shopIRigth10" disabled type="text" placeholder="店铺" style="border:0;"/>
                        <div class="input-group-btn shopDRingth mediaSm inputMenu">
                            <button type="button" class="btns dropdown-toggle btnMedia" style="background:#E9E9E9!important;"  aria-haspopup="true" aria-expanded="false">
                                <b class="arrow fa fa-angle-down dwonStle"></b>
                            </button>
                            <ul class="dropdown-menu downBtn mediaDownBtn proportion">
                                <li><a href="#">全部</a></li>
                                <volist name="marketsList" id="vo">
                                    <if condition="$vo.isActive == 1">
                                        <li><a href="#" value="{$vo.ID}">{$vo.UserMarketCNName}</a></li>
                                    </if>
                                </volist>
                            </ul>
                        </div>
                    </div>

                </div>
                <div class="col-xs-12 labeiTop20 shopleft0 shopright0 marginBottom30">
                    <table class="table table-striped table-bordered table-hover dataTable" style="margin-bottom: 0px;">
                        <thead>
                        <tr class="tableStyle size14">
                            <th style="width: 50px;">状态</th>
                            <th>Buybox状态</th>
                            <th class="table-shop-tdW">店铺名称</th>
                            <th style="width: 70px;">SKU</th>
                            <th style="width: 75px;">发货方式</th>
                            <th>ASIN</th>
                            <th>商品名称</th>
                            <th class="table-shop-tdW">创建时间</th>
                            <th class="sorting dynamicTable" order="SaleReportIn30Days" style="color:#666666!important;width: 120px;">
                                近30天售出
                            </th>
                            <th class="tableTdW sorting dynamicTable" order="Quantity" style="color:#666666!important;width: 108px;">可售</th>
                            <!--<th>竞争对手</th>-->
                            <th>Buybox价格</th>
                            <th class="tableTdW" style="width: 140px;">销售价格+配送费</th>
                        </tr>
                        </thead>
                        <tbody class="contrast shopCont tableLineH" id="productList">
                        </tbody>
                    </table>

                    <div class="dataTables_paginate paging_simple_numbers pagingTr" id="dynamic-table_paginate">
                        <ul class="pagination productPagination">
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <div class="shoptable2">
            <div class="shopContainer priceAdjustmentRecord">
                <div class="col-lg-4 col-sm-12 shopleft0 shopright0 shopBottmMedia" id="shopMediaBtn">
                    <input type="hidden" name="shopName">
                    <input class="col-sm-11 col-lg-11 shopInput proportionInput shopFloat shopPadding10 " type="text" placeholder="按店铺选择" disabled style="border:0;" />
                    <div class="input-group-btn shopFloat inputMenus">
                        <button type="button" class="btns dropdown-toggle" style="background:#E9E9E9!important;" aria-haspopup="true" aria-expanded="false">
                            <b class="arrow fa fa-angle-down dwonStle"></b>
                        </button>
                        <ul class="dropdown-menu shopDownBtn  proportion">
                            <li><a href="#">全部</a></li>
                            <volist name="marketsList" id="vo">
                                <if condition="$vo.isActive == 1">
                                    <li><a href="#" value="{$vo.ID}">{$vo.UserMarketCNName}</a></li>
                                </if>
                            </volist>
                        </ul>
                    </div>
                </div>
                <div class="col-lg-4 col-sm-12  shopBottmMedia shopleft0 shopright0 text-center">
                    <div class="col-lg-11 col-md-11 col-sm-11 shopleft0 shopright0 shopPosition">
                        <input class="col-sm-12 col-lg-11 shopInput proportionInput shopPadding10 mediaRight time-input-media" name="ASIN" type="text" placeholder="请输入ASIN" style="border:0;" />
                        <i class="ace-icon fa fa-times shopClose priceAdjustmentRecordShopClose" style="display: none"></i>
                    </div>
                    <div class=" text-center mediaLeft productSearch" style="width: 0;">
                        <span class=" input-icon" >
                            <i class="ace-icon fa fa-search nav-search-icon"></i>
                        </span>
                    </div>
                </div>

                <div class="col-lg-4 col-sm-12 shopleft0 shopright0">
                    <div class="col-lg-11 col-md-11 col-sm-11 shopleft0 shopright0 shopPosition">
                        <input class="shopInputs shopFloat proportionInput col-lg-11  col-sm-12 time-input-media" name="createTime" id="datepicker" type="text" placeholder="按日期筛选" style="border:0;">
                        <i class="ace-icon fa fa-times shopClose priceAdjustmentRecordShopClose" style="display: none"></i>
                    </div>
                    <div class="col-lg-1 col-sm-1 shopleft0 shopright0 shopFloatLeft">
                            <span class=" input-icon">
                                <i class="ace-icon fa fa-calendar nav-search-icon "></i>
                            </span>
                    </div>
                </div>

                <div class="col-xs-12 labeiTop20 shopleft0 shopright0 labeiPaddingBt30">
                    <table id="table" class="table table-striped table-bordered table-hover" style="margin-bottom: 0px;">
                        <thead>
                        <tr class="tableStyle size14">
                            <th>ASIN</th>
                            <th>发货方式</th>
                            <th>调整时Buybox价格</th>
                            <th>调整前商品价格</th>
                            <th>调整后商品价格</th>
                            <th>变动价格</th>
                            <th>调价时间</th>
                        </tr>
                        </thead>

                        <tbody class="contrast" id="modifypricehistoryList">
                        <volist name="modifypricehistoryData[8]" id="vo">
                            <tr class="trColor">
                                <td><a href="{$vo.ASIN_URL}" class="shopAndTd">{$vo.ASIN}</a></td>
                                <td>{$vo.DespatchModeType}</td>
                                <td>{$vo.BuyboxPrice}</td>
                                <td>{$vo.BeforeModifyPrice}</td>
                                <td>{$vo.AfterModifyPrice}</td>
                                <td>{$vo.AlterationPrice}</td>
                                <td>{$vo.ModifyPriceTime|date='Y/m/d H:i:s',###}</td>
                            </tr>
                        </volist>
                        </tbody>
                    </table>
                    <div class="dataTables_paginate paging_simple_numbers pagingTr" id="dynamic-table_paginate">
                        <ul class="pagination modifypricehistoryPagination">
                            {$modifypricehistoryData[3]}
                            {$modifypricehistoryData[1]}
                            {$modifypricehistoryData[4]}
                            {$modifypricehistoryData[2]}
                            {$modifypricehistoryData[5]}
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <!-- /.main-content -->
    </div>
    <!--结束 商品调价-->
    <style type="text/css">
        #preview {
            width:100%;
            height:100%;
            position: fixed;
            top:0;
            left:0;
            background: #E9E9E9;
            opacity: .5;
            filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50);
            -ms-filter: filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50);
            z-index: 1030;
            display: none;
        }
    </style>
    <section id="preview"></section>
</block>

<!-- 开始 页面 级 代码 -->
<block name="JAVASCRIPT_PAGE_LEVEL_CODE">
    <script>
        $(function(){

            /**
             * 格式化时间  时间戳 转 时间
             * @param d
             * @returns {string}
             */
            var getStrTime = function(d,c) {
                if(!d){
                    return '';
                }
                var   now    = new   Date(parseInt(d) * 1000);
                var   year   = now.getFullYear();
                var   month  = now.getMonth()+1;
                var   date   = now.getDate();
                var   hour   = now.getHours();
                var   minute = now.getMinutes();
                var   second = now.getSeconds();
                var str = (c) ? year+"/"+month+"/"+date+" "+hour+":"+minute+":"+second : year+"/"+month+"/"+date+"<br/>"+hour+":"+minute+":"+second;
                return   str;
            }

            /**
             *  商品 调价 ajax 分页加载
             *  @author xiaojin
             */
            $('.productPagination').on('click','a',function(){

                var url  = $(this).attr('hrefs');

                var page  = $(this).attr('page');

                var data =  getRequestData();

                if(page && url){
                    data.page = page;
                    productRendering(url,data);
                }

            });

            /**
             *商品调价下拉列表
             **/
            var menuClick = $(".inputContai").find(".menuClick");
            menuClick.on("click",function(e){
                if($(this).children(".inputMenu").hasClass("open")){
                    $(this).children("div").removeClass("open");
                }else{
                    $(this).children("div").addClass("open");
                    $(this).siblings().children("div").removeClass("open");
                }
                e.stopPropagation();
            });

            /**
             *  商品 调价 下拉 筛选
             *  @author xiaojing
             */
            $('.productScreen .proportion').find('li').on('click',function(){

                $(this).parent().parent().siblings("input[type='text']").val($(this).children().html());

                $(this).parent().parent().siblings("input[type='hidden']").val($(this).children().attr('value'));

                productRendering('index.php?s=/home/index/getajaxproduct',getRequestData());

            });

            /**
             * 商品 调价 搜索 筛选
             * @author xiaojing
             */
            $('.productScreen .productSearch').on('click',function(){
                $(this).prev().find('i').show();
                productRendering('index.php?s=/home/index/getajaxproduct',getRequestData());
            });

            /**
             * 商品 调价 清空 搜索 筛选 内容
             * @author xiaojing
             */
            $('.productShopClose').on('click',function(){

                $(this).hide();

                $(this).prev('input').val('');

                productRendering('index.php?s=/home/index/getajaxproduct',getRequestData());
            });

            /**
             *  商品 调价 导出
             *  @author xiaojing
             */
            $('.exportProductData').on('click',function(){

                var ASINorSellerSKU  = $('.productScreen').find("input[name='ASINorSKU']").val(); //ASIN 或 SKU

                var ProductStatus    = $('.productScreen').find("input[name='listingStatus']").val(); //产品状态

                var BuyBoxStatus     = $('.productScreen').find("input[name='buyboxStatus']").val(); //buybos状态

                var Quantity         = $('.productScreen').find("input[name='quantity']").val(); //数量

                var DespatchModeType = $('.productScreen').find("input[name='FBAorFBM']").val(); //发货类型

                //var rivalQty      = $('.productScreen').find("input[name='rivalQty']").val();

                $.post('index.php?s=/home/index/exportproductdata',{
                    ASINorSellerSKU:ASINorSellerSKU,
                    ProductStatus:ProductStatus,
                    BuyBoxStatus:BuyBoxStatus,
                    Quantity:Quantity,
                    DespatchModeType:DespatchModeType,
                },function(res){
                    res = JSON.parse(res);
                    if(res.url){
                        window.location.href = res.url;
                    }
                });
            });

            /**
             *  获取 商品 调价 筛选 项 数据
             * @returns {{ASINorSellerSKU: (*|jQuery), ProductStatus: (*|jQuery), BuyBoxStatus: (*|jQuery), Quantity: (*|jQuery), DespatchModeType: (*|jQuery)}}
             */
            var getRequestData = function(){

                var ASINorSellerSKU  = $('.productScreen').find("input[name='ASINorSKU']").val(); //ASIN 或 SKU

                var ProductStatus    = $('.productScreen').find("input[name='listingStatus']").val(); //产品状态

                var BuyBoxStatus     = $('.productScreen').find("input[name='buyboxStatus']").val(); //buybos状态

                var Quantity         = $('.productScreen').find("input[name='quantity']").val(); //数量

                var DespatchModeType = $('.productScreen').find("input[name='FBAorFBM']").val(); //发货类型

                var MarketID         = $('.productScreen').find("input[name='shopName']").val(); //所选商店

                //var rivalQty      = $('.productScreen').find("input[name='rivalQty']").val();

                return {
                    ASINorSellerSKU:ASINorSellerSKU,
                    ProductStatus:ProductStatus,
                    BuyBoxStatus:BuyBoxStatus,
                    Quantity:Quantity,
                    DespatchModeType:DespatchModeType,
                }
            }

            /**
             * 商品 调库存 保存按钮 显示
             * @author xiaojing
             */
            $("#productList").on('keyup','.productQuantity',function(){
                var value = $(this).val().replace(/[^\d]/g,'');
                $(this).val(value);
                $(this).siblings(".saveProductQuantity").show();
            })

            /**
             * 调库存保存
             * @author xiaojing
             */
            $('#productList').on('click','.saveProductQuantity',function(){

                var MarketID =  $(this).parent().prevAll('.productMarketID').val();

                var SellerSKU = $(this).parent().prevAll('.productSellerSKU').val();

                var Quantity = $(this).prev('.productQuantity').val();

                $.post('index.php?s=/home/index/saveproductadjustment',{MarketID:MarketID,SellerSKU:SellerSKU,Quantity:Quantity},function(res){
                    console.log(res);
                    var page = $('.productPagination').find('.active').find('a');
                    page.attr({'hrefs':'index.php?s=/home/index/getajaxproduct','page':page.text()});
                    page.trigger('click');
                },'JSON');

                $(this).hide();

            });

            /**
             * 调价保存
             * @author xiaojing
             */
            $("#productList").on('click','.saveProducPrice',function(){

                var MarketID = $(this).parent().prevAll('.productMarketID').val();

                var SellerSKU = $(this).parent().prevAll('.productSellerSKU').val();

                var Price = $(this).prev('.producPrice').val();

                $.post('index.php?s=/home/index/saveproductadjustment',{MarketID:MarketID,SellerSKU:SellerSKU,Price:Price},function(res){
                    var page = $('.productPagination').find('.active').find('a');
                    page.attr({'hrefs':'index.php?s=/home/index/getajaxproduct','page':page.text()});
                    page.trigger('click');
                },'JSON');

                $(this).hide();

            });

            /**
             * 商品调价 升序降序按钮功能
             * */
            var dynamicTable = $(".dataTable thead").find(".dynamicTable");
            dynamicTable.on("click",function(){
                var orderType = $(this).attr('order');
                var  orderStatus = '';
                if($(this).hasClass("sorting_asc")){
                    orderStatus = 'ASC';
                    $(this).addClass("sorting_desc").removeClass("sorting sorting_asc").siblings(".dynamicTable").addClass("sorting").removeClass("sorting_desc sorting_asc sorting_desc");
                }else{
                    orderStatus = 'DESC';
                    $(this).addClass("sorting_asc").removeClass("sorting sorting_desc").siblings(".dynamicTable").addClass("sorting").removeClass("sorting_asc sorting_desc");
                }
                var data =  getRequestData();
                data.orderStatus = orderStatus;
                productRendering('index.php?s=/home/index/getajaxproduct',data);
            });

            /**
             * 商品 调价 表渲染
             * @param url
             * @param parameter
             */
            var productRendering = function(url,parameter){

                $('#preview').show(); //显示 loding 模糊窗

                if($('#preview').html() == ''){ // 判断 是否已经创建 loding

                    new Spinner().spin(document.getElementById('preview'));//创建loding
                }
                $.post(url,parameter,function(res){
                    console.log(res);
                    if(res['state'] == 202){
                        setTimeout(function() {productRendering(url,parameter);},3000);
                        return false;//防止走下一步的逻辑
                    }
                    //隐藏 loding 模糊窗
                    $('#preview').hide();

                    var pageHtml = '';
                    if(res['data'][4]){
                        var pageHtml = res['data'][3];
                        pageHtml = pageHtml+ res['data'][1];
                        pageHtml = pageHtml+ res['data'][4];
                        pageHtml = pageHtml+ res['data'][2];
                        pageHtml = pageHtml+ res['data'][5];
                    }

                    $('.productPagination').html(pageHtml);

                    var productList = '';

                    var datalist = res['data'][8];

                    if(datalist.length > 0){
                        for(var i =0; datalist.length > i; i++){
                            if(!datalist[i]['MarketID']){
                                $('#productList').html('');
                                return false;
                            }
                            productList = productList +'<tr class="trColor">' +
                                    '<input class="productMarketID" type="hidden" value="'+datalist[i]['MarketID']+'"/>' +
                                    '<input class="productSellerSKU" type="hidden" value="'+datalist[i]['SellerSKU']+'"/>';

                            if(datalist[i]['ProductStatus'] == 1){
                                productList = productList + '<td class="tablePadding">可售</td>';
                            }else if(datalist[i]['ProductStatus'] == 2){
                                productList = productList + '<td class="tablePadding">不可售</td>';
                            }else{
                                productList = productList + '<td class="tablePadding">暂未获取</td>';
                            }

                            if(datalist[i]['BuyBoxStatus'] == 1){
                                productList = productList + '<td class="tablePadding">已抢占</td>';
                            }else if(datalist[i]['BuyBoxStatus'] == 2){
                                productList = productList + '<td class="tablePadding">未抢占</td>';
                            }else{
                                productList = productList + '<td class="tablePadding">暂未获取</td>';
                            }

                            productList = productList + '<td class="tablePadding">'+datalist[i]['UserMarketCNName']+'</td>' +
                                                        ' <td class="tablePadding">'+datalist[i]['SellerSKU']+'</td>' +
                                                        '<td class="tablePadding">'+datalist[i]['DespatchModeType']+'</td>' +
                                                        '<td class="tablePadding"><a href="'+datalist[i]['ASIN_URL']+'" class="shopAndTd" target="_blank">'+datalist[i]['ASIN']+'</a></td>' +
                                                        '<td class="tablePadding">'+datalist[i]['ProductName']+'</td>' +
                                                        '<td class="tablePadding">'+getStrTime(datalist[i]['createtime'],false)+'</td>' +
                                                        '<td class="tablePadding">'+datalist[i]['SaleReportIn30Days']+'</td>';

                            if(datalist[i]['DespatchModeType'] == 'FBA'){
                                productList = productList + '<td class="tablePadding"><span>'+datalist[i]['Quantity']+'</span></td>';
                            }else{
                                productList = productList + '<td class="tablePadding"><input id="inputStyle" type="text" class="savaBtnClicks productQuantity" value="'+datalist[i]['Quantity']+'"/>' +
                                                            '<i class="ace-icon fa fa-floppy-o bigger-120 color9 saveProductQuantity savaHover" style="font-size: 150%!important;display: none;"></i>' +
                                                            '</td>';
                            }
                            productList = productList +'<td class="tablePadding">'+datalist[i]['BuyBoxPrice']+'</td>' +
                                                        '<td class="tablePadding">' +
                                                        '<input id="inputStyle" type="text" class="savaBtnClick producPrice" value="'+datalist[i]['Price']+'"/>' +
                                                        '<i class="savalogo ace-icon fa fa-floppy-o bigger-120 color9 saveProducPrice" style="font-size: 150%!important;display: none"></i>' +
                                                        '<p>(Your Price)+$0</p>' +
                                                        '</td>' +
                                                        '</tr>';
                            }
                        $('#productList').html(productList);
                    }
                },'JSON');
            }

            /**
             * 加载 商品 调价 数据
             * @author xiaojing
             */
            var inits =  function(){
                $.ajax({type:'post',url:'index.php?s=/home/index/getmarketsstatus',async:false,success:function(res){
                    if(res.marketsStatus != 1){
                        window.location.href  = '/index.php?s=/home/index/amazonauthmarkest';
                    }else{
                        productRendering('index.php?s=/home/index/getajaxproduct',{});
                    }
                },dataType:'json'});
            }();



            /**
             * 点击 调价 记录 加载
             * @author xiaojing
             */
            $('#choiceModifypricehistoryPagination').on('click',function(){
                adjustmentRecordRendering('index.php?s=/home/index/getajaxusermodifypricehistory',{});
            });

            /**
             *  调价记录  ajax 分页加载
             *  @author xiaojin
             */
            $('.modifypricehistoryPagination').on('click','a',function(){

                var url              = $(this).attr('hrefs');

                var page             = $(this).attr('page');

                var MarketID         = $('.priceAdjustmentRecord').find("input[name='shopName']").val();

                var ASIN             = $('.priceAdjustmentRecord').find("input[name='ASIN']").val();

                var ModifyPriceTime  = $('.priceAdjustmentRecord').find("input[name='createTime']").val();

                adjustmentRecordRendering(url,{
                    page:page,
                    MarketID:MarketID,
                    ASIN:ASIN,
                    ModifyPriceTime:ModifyPriceTime
                });

            });

            /**
             * 调价 历史 下拉 列表
             **/
            $("#shopMediaBtn").on("click",function(){
                if($(".inputMenus").hasClass("open")){
                    $(this).children("div").removeClass("open").children("button").attr("aria-expanded","false");
                }else{
                    $(this).children("div").addClass("open").children("button").attr("aria-expanded","true");
                }

            });

            /**
             *  调价 记录 下拉 筛选
             *  @author xiaojing
             */
            $('.priceAdjustmentRecord .proportion').find('li').on('click',function(){

                $(this).parent().parent().siblings("input[type='text']").val($(this).children().html());

                $(this).parent().parent().siblings("input[type='hidden']").val($(this).children().attr('value'));

                var MarketID         = $('.priceAdjustmentRecord').find("input[name='shopName']").val();

                var ASIN             = $('.priceAdjustmentRecord').find("input[name='ASIN']").val();

                var ModifyPriceTime  = $('.priceAdjustmentRecord').find("input[name='createTime']").val();

                adjustmentRecordRendering('index.php?s=/home/index/getajaxusermodifypricehistory',{
                    MarketID:MarketID,
                    ASIN:ASIN,
                    ModifyPriceTime:ModifyPriceTime
                });
            });

            /**
             * 调价记录 搜索 筛选
             * @author xiaojing
             */
            $('.priceAdjustmentRecord .productSearch').on('click',function(){
                $(this).prev().find('i').show();
                var MarketID         = $('.priceAdjustmentRecord').find("input[name='shopName']").val();
                var ASIN             = $('.priceAdjustmentRecord').find("input[name='ASIN']").val();
                var ModifyPriceTime  = $('.priceAdjustmentRecord').find("input[name='createTime']").val();
                adjustmentRecordRendering('index.php?s=/home/index/getajaxusermodifypricehistory',{
                    MarketID:MarketID,
                    ASIN:ASIN,
                    ModifyPriceTime:ModifyPriceTime
                });
            });

            /**
             * 调价记录  日期 筛选
             * @author xiaojing
             */
            $('#datepicker').datepicker({
                dateFormat: 'yy-mm-d',
                showOtherMonths: true,
                selectOtherMonths: false,
                onSelect:function(dateText, inst){

                    $('#datepicker').next().show(); //显示清空按钮

                    var MarketID         = $('.priceAdjustmentRecord').find("input[name='shopName']").val();

                    var ASIN             = $('.priceAdjustmentRecord').find("input[name='ASIN']").val();

                    //var ModifyPriceTime  =  Date.parse(new Date(dateText));

                    var ModifyPriceTime  =  dateText;

                    adjustmentRecordRendering('index.php?s=/home/index/getajaxusermodifypricehistory',{
                        MarketID:MarketID,
                        ASIN:ASIN,
                        ModifyPriceTime:ModifyPriceTime
                    });
                    return false;
                }
            });

            /**
             * 调价记录 清空 搜索/时间 筛选 内容
             * @author xiaojing
             */
            $('.priceAdjustmentRecordShopClose').on('click',function(){

                $(this).hide();

                $(this).prev('input').val('');

                var MarketID         = $('.priceAdjustmentRecord').find("input[name='shopName']").val();

                var ASIN             = $('.priceAdjustmentRecord').find("input[name='ASIN']").val();

                var ModifyPriceTime  = $('.priceAdjustmentRecord').find("input[name='createTime']").val();

                adjustmentRecordRendering('index.php?s=/home/index/getajaxusermodifypricehistory',{
                    MarketID:MarketID,
                    ASIN:ASIN,
                    ModifyPriceTime:ModifyPriceTime
                });

            });

            /**
             * 调价历史表渲染
             * @param url
             * @param parameter
             */
            var adjustmentRecordRendering  = function(url,parameter){
                $.post(url,parameter,function(res){
                    var pageHtml = '';
                    if(res['data'][4]){
                        var pageHtml = res['data'][3];
                        pageHtml = pageHtml+ res['data'][1];
                        pageHtml = pageHtml+ res['data'][4];
                        pageHtml = pageHtml+ res['data'][2];
                        pageHtml = pageHtml+ res['data'][5];
                    }
                    $('.modifypricehistoryPagination').html(pageHtml);

                    var modifypricehistoryList = '';

                    var datalist = res['data'][8];
                    if(datalist.length > 0){
                        for(var i =0; datalist.length > i; i++){

                            if(!datalist[i]['MarketID']){
                                $('#modifypricehistoryList').html('');
                                return false;
                            }

                            var modifypricehistoryList = modifypricehistoryList +'<tr class="trColor">' +
                                    '<td><a href="'+datalist[i]['ASIN_URL']+'" class="shopAndTd">'+datalist[i]['ASIN']+'</a></td>' +
                                    '<td>'+datalist[i]['DespatchModeType']+'</td>' +
                                    '<td>'+datalist[i]['BuyboxPrice']+'</td>' +
                                    '<td>'+datalist[i]['BeforeModifyPrice']+'</td>' +
                                    '<td>'+datalist[i]['AfterModifyPrice']+'</td>' +
                                    '<td>'+datalist[i]['AlterationPrice']+'</td>';
                            modifypricehistoryList = modifypricehistoryList +  '<td>'+getStrTime(datalist[i]['ModifyPriceTime'],true);+'</td>';
                        }

                        $('#modifypricehistoryList').html(modifypricehistoryList);
                    }
                },'JSON');
            }

        })
    </script>
</block>
<!-- 结束 页面 级 代码 -->